let mongoose=require('mongoose');

mongoose.connect('mongodb://localhost:27017/Index')
const con=mongoose.connection
con.once('open',()=>{console.log("打开成功")})
// 定义所有期
// let allIssuesSchema=new mongoose.Schema({
//     id:Number,
//     name:String,
//     start_time: String,
//     end_time: String,
// })
// 发布所有的试题和试卷分类模型
// let allIssuesModel=con.model('allIssues',allIssuesSchema,'allIssues');
var myDate=new Date()

function timeToString(timeObj){
         var str = "";
         var year = timeObj.getFullYear();
         var month = timeObj.getMonth();
         var date = timeObj.getDate();
         //var time = timeObj.toTimeString().split(" ")[0];
         //var rex = new RegExp(/:/g);
         //str = year+"-"+month+"-"+date+" "+time.replace(rex,":");
         str = year+"."+month+"."+date;
        console.log("------当前日期："+str);
        console.log("------当前日期："+str);
        return str;
    }
// allIssuesModel.create([{
//     id:1,
//     name:"十九中全会",
    start_time:timeToString(myDate),
//     end_time:timeToString(myDate),
// },{
//     id:2,
//     name:"十八中全会",
//     start_time:timeToString(myDate),
//     end_time:timeToString(myDate),

// }])

// let allPapersSchema=new mongoose.Schema({
//     belongToIssue:Number,
//     name:String,
//     id: Number,
// })
 
// let allPapersModel=con.model('allPapers',allPapersSchema,'allPapers');
// allPapersModel.create([{
//     belongToIssue:1,
//     name:"试卷A",
//     id:1
// },{
//     belongToIssue:1,
//     name:"试卷B",
//     id:2
// },{
//     belongToIssue:1,
//     name:"试卷C",
//     id:3
// },{
//     belongToIssue:2,
//     name:"试卷D",
//     id:4
// },{
//     belongToIssue:2,
//     name:"试卷E",
//     id:5
// },{
//     belongToIssue:2,
//     name:"试卷F",
//     id:6
// },{
//     belongToIssue:3,
//     name:"试卷G",
//     id:7
// },{
//     belongToIssue:3,
//     name:"试卷H",
//     id:8
// },{
//     belongToIssue:4,
//     name:"试卷I",
//     id:9
// },{
//     belongToIssue:4,
//     name:"试卷J",
//     id:10
// },{
//     belongToIssue:5,
//     name:"试卷K",
//     id:11
// },{
//     belongToIssue:5,
//     name:"试卷L",
//     id:12
// },{
//     belongToIssue:5,
//     name:"试卷M",
//     id:13
// }
// ])

let allQuestionsSchema=new mongoose.Schema({
    belongToPaper:Number,
    type:Number,
    id: Number,
})
let allQuesetionsModel=con.model('allQuestions',allQuestionsSchema,'allQuestions');
allQuesetionsModel.create([{
    belongToPaper:1,
    type:0,
    id:1
},{
    belongToPaper:1,
    type:0,
    id:2
},{
    belongToPaper:1,
    type:1,
    id:3
},{
    belongToPaper:1,
    type:2,
    id:4
},{
    belongToPaper:1,
    type:3,
    id:5
},{
    belongToPaper:2,
    type:0,
    id:6
},{
    belongToPaper:2,
    type:0,
    id:2
},{
    belongToPaper:1,
    type:0,
    id:2
}
])


// 定义所有选择题
let allSelectQuestionsSchema=new mongoose.Schema({
    id:Number,
    discript:String,
    optionA:String,
    optionB:String,
    optionC:String,
    optionD:String,
    answer: String,
})
let allSelectQuestionsModel=conn.model('allSelectQuestions',allSelectQuestionsSchema,'allSelectQuestions');

// 定义所有判断题
let allJudgeQuestionsSchema=new mongoose.Schema({
    id:Number,
    discript:String,
    answer: Boolean,
})
let allJudgeQuestionsModel=conn.model('allJudgeQuestions',allJudgeQuestionsSchema,'allJudgeQuestions');

// 定义所有填空题
let allCompleteQuestionsSchema=new mongoose.Schema({
    id:Number,
    discript:String,
    answer: String,
})
let allCompleteQuestionsModel=conn.model('allCompleteQuestions',allCompleteQuestionsSchema,'allCompleteQuestions');
